package exp5;

class Complex extends Object {
	int real, image;

	public static void equals(Complex a, Complex b) {
		if (a.real == b.real && a.image == b.image) {
			System.out.println("两复数相等！");
		} else {
			System.out.println("两复数不相等！");
		}
	}

	public int getReal() {
		return real;
	}

	public void setReal(int real) {
		this.real = real;
	}

	public int getImage() {
		return image;
	}

	public void setImage(int image) {
		this.image = image;
	}

	Complex(int real, int image) {
		this.real = real;
		this.image = image;
	}


	void printInfo() {
		System.out.println("Complex [real=" + this.real + ", image=" + this.image + "]");
	}

	Complex add(Complex anotherComplex) {
		Complex t = new Complex(this.real + anotherComplex.real, this.image + anotherComplex.image);
		return t;
	}

}

public class ComplexTest {
	public static void main(String[] args) {
		Complex complex1 = new Complex(1, 1);
		Complex complex2 = new Complex(3, 1);
		Complex complex3 = new Complex(0, 0);
		complex1.setReal(3);
		System.out.println(complex1.getReal());
		complex1.printInfo();
		complex3 = complex1.add(complex2);
		complex3.printInfo();
		Complex.equals(complex1, complex2);
	}
}
